﻿using System;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;

namespace HamcoWcs.DAL.Migrations
{
    public partial class A8 : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropColumn(
                name: "CreatedTime",
                table: "device_error_log_bak");

            migrationBuilder.DropColumn(
                name: "LastUpdateTime",
                table: "device_error_log_bak");

            migrationBuilder.DropColumn(
                name: "CreatedTime",
                table: "device_error_log");

            migrationBuilder.DropColumn(
                name: "LastUpdateTime",
                table: "device_error_log");

            migrationBuilder.AddColumn<DateTime>(
                name: "OccurTime",
                table: "device_error_log_bak",
                type: "datetime(6)",
                nullable: false,
                defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
                comment: "发生时间");

            migrationBuilder.AddColumn<DateTime>(
                name: "OccurTime",
                table: "device_error_log",
                type: "datetime(6)",
                nullable: false,
                defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
                comment: "发生时间");

            migrationBuilder.CreateTable(
                name: "device_error_info",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false, comment: "主键Id")
                        .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
                    PlcName = table.Column<string>(type: "varchar(30)", maxLength: 30, nullable: false, comment: "PLC名")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    DeviceName = table.Column<string>(type: "varchar(30)", maxLength: 30, nullable: false, comment: "设备名")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    ErrorCode = table.Column<string>(type: "varchar(30)", maxLength: 30, nullable: false, comment: "异常代码")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    ErrorDetail = table.Column<string>(type: "varchar(255)", maxLength: 255, nullable: false, comment: "异常说明")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    OccurTime = table.Column<DateTime>(type: "datetime(6)", nullable: false, comment: "发生时间")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_device_error_info", x => x.Id);
                },
                comment: "当前设备异常")
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "srm_info",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false, comment: "主键Id")
                        .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
                    SrmName = table.Column<string>(type: "varchar(30)", maxLength: 30, nullable: false, comment: "堆垛机名")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    MachineName = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: true, defaultValue: "", comment: "机器名")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    PortName = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: true, defaultValue: "", comment: "端口名")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    PlcName = table.Column<string>(type: "varchar(30)", maxLength: 30, nullable: false, comment: "PLC名")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    SendStartPoint = table.Column<int>(type: "int", nullable: false, comment: "发送DB偏移量"),
                    RecvStartPoint = table.Column<int>(type: "int", nullable: false, comment: "接收DB偏移量")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_srm_info", x => x.Id);
                },
                comment: "堆垛机信息表")
                .Annotation("MySql:CharSet", "utf8mb4");
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "device_error_info");

            migrationBuilder.DropTable(
                name: "srm_info");

            migrationBuilder.DropColumn(
                name: "OccurTime",
                table: "device_error_log_bak");

            migrationBuilder.DropColumn(
                name: "OccurTime",
                table: "device_error_log");

            migrationBuilder.AddColumn<DateTime>(
                name: "CreatedTime",
                table: "device_error_log_bak",
                type: "datetime(6)",
                nullable: false,
                defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));

            migrationBuilder.AddColumn<DateTime>(
                name: "LastUpdateTime",
                table: "device_error_log_bak",
                type: "datetime(6)",
                nullable: false,
                defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));

            migrationBuilder.AddColumn<DateTime>(
                name: "CreatedTime",
                table: "device_error_log",
                type: "datetime(6)",
                nullable: false,
                defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));

            migrationBuilder.AddColumn<DateTime>(
                name: "LastUpdateTime",
                table: "device_error_log",
                type: "datetime(6)",
                nullable: false,
                defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
        }
    }
}
